package com.wyd.common.base;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.util.UUID;

@Getter
@ToString(callSuper = true)
@MappedSuperclass
public abstract class BaseEntity extends TimedEntity {
    @Id
    @ApiModelProperty(hidden = true)
    @Column(length = 36)
    private String uuid;

    @Override
    protected void prePersist() {
        super.prePersist();
        this.uuid = UUID.randomUUID().toString().replace("-", "");
    }
}
